<template>
  <div>
    <station-category-chart :evaluate-config="evaluateConfig" @show="show" v-if="type === $t('common.tabs.event')" :state="state" />
    <staff-category-chart :evaluate-config="evaluateConfig" @show="show" v-if="type === $t('common.base.task') || type === $t('common.base.customer')" :state="state" :type="type" />
  </div>
</template>
<script>
import { t } from '@src/locales';
import StaffCategoryChart from './StaffCategoryChart.vue';
import StationCategoryChart from './StationCategoryChart.vue';
import { isBasicEditionHideEvent } from '@shb-lib/version'

export default {
  name: 'staff-efficiency-view',
  data() {
    return {
      evaluateConfig: {},
      type: t('common.tabs.event'),
      state: ''
    }
  },
  computed: {
    // 基础版功能是否隐藏事件
    isBasicEditionHideEvent() {
      return isBasicEditionHideEvent() 
    },
  },
  watch: {
    isBasicEditionHideEvent: {
      immediate: true,
      handler(newValue, _) {
        this.type = newValue ? this.$t('common.base.task') : this.$t('common.tabs.event')
      }
    }
  },
  methods:{
    show(v) {
      this.type = v    
    }
  },
  created () {
    localStorage.removeItem('tag')
    localStorage.setItem('ignoreDeleted', true)
    localStorage.setItem('categoryIgnoreNull', true)
  },
  mounted() {
    this.state = window.location.href.split('type=')[1]
    console.log('this.state222', this.state);
    let initData = JSON.parse(sessionStorage.getItem('_init_data'))
    this.evaluateConfig = initData.evaluateConfig || {};
    localStorage.removeItem("taskTypesList")
    localStorage.removeItem("timeType")
    localStorage.removeItem('staffEfficiency')
    localStorage.removeItem('tag')
  },
  // destroyed() {
  //   localStorage.removeItem("taskTypesList")
  //   localStorage.removeItem("timeType")
  //   localStorage.removeItem('staffEfficiency')
  // },
  components: {
    [StaffCategoryChart.name]: StaffCategoryChart,
    [StationCategoryChart.name]: StationCategoryChart
  } 
}
</script>
